import Vue from 'vue'
import Router from 'vue-router'

import Main from '../views/Main'
import Login from '../views/Login'

import UserList from '../views/user/List'
import UserProfile from '../views/user/Profile'
import NotFound from '../views/NotFound'

Vue.use(Router);

export default new Router({
  /**
   * 路由模式有两种
   * hash：路径到#符号：如http://localhost/#/login
   * history:路径没有#：如http://localhost/login
   */
  mode:'history',//不显示#号地址
  routes:[
    {
      path:'/main/:name',
      component:Main,
      props:true,
      children: [
        {path:'/user/list', component:UserList },
        {path:'/user/profile/:id', name:'UserProfile', component:UserProfile,props:true}
      ]
    },
    {
      path:'/login',
      component:Login//嵌套路由
    },
    {
      path:'goHome',
      redirect:'/main'
    },
    {
      path:'*',
      component: NotFound
    }
  ]
})
